﻿/*===================================================
* CLR版本  : 4.0.30319.42000 
* 类名称   : IUIFactory
* 文 件 名 : IUIFactory 
* 类描述   :
* 创建人   : oream
* 创建时间 : 2018/2/14 22:21:45
* 修改人   : 
* 修改时间 :
* 版本： @version 1.0
=====================================================*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Hotfix
{
  public abstract class AbsUIFactory
  {
    public abstract UI Create(Scene scene, EnumUiType uiType, GameObject parentComponentOjbect);
    public abstract void Remove(EnumUiType uiType);

    public GameObject gameObject;


    #region UI窗体属性&字段
    /// <summary>
    /// UI的当前窗体属性
    /// </summary>
    private UIType _uiType = new UIType();

    /// <summary>
    /// 设置当前UI的窗体属性
    /// </summary>
    internal UIType SetUIType
    {
      get
      {
        return _uiType;
      }
      set
      {
        _uiType = value;
      }
    }

    public string ThisUIName { get; set; }

    #endregion

    public void Add(EnumUiType uiType)
    {
      UIManager.Instance.AddUi(this.gameObject, uiType.ToString(), this);
    }


    #region UI窗体方法

    /// <summary>
    /// 显示页面
    /// </summary>
    public virtual void Display()
    {
      this.gameObject.SetActive(true);
      if (SetUIType._UIFormType == EnumUIFormType.PopUp)
      {
        UIMaskMgr.Instance.SetMeskWindew(this.gameObject, SetUIType._UIFormLucancyType);
      }
    }

    /// <summary>
    /// 界面隐藏 (不在栈集合中)
    /// </summary>
    public virtual void Hiding()
    {
      this.gameObject.SetActive(false);
      if (SetUIType._UIFormType == EnumUIFormType.PopUp)
      {
        UIMaskMgr.Instance.CancelMaskWindew();
      }
    }

    /// <summary>
    /// 页面重新显示
    /// </summary>
    public virtual void Redisplay()
    {
      this.gameObject.SetActive(true);
      if (SetUIType._UIFormType == EnumUIFormType.PopUp)
      {
        UIMaskMgr.Instance.SetMeskWindew(this.gameObject, SetUIType._UIFormLucancyType);
      }
    }

    /// <summary>
    /// 页面冻结(还在"栈"集合中)
    /// </summary>
    public virtual void Freeze()
    {
      gameObject.SetActive(true);
    }


    #endregion



  }
}
